package cn.edu.xmu.restfuldemo.model.VO;

import cn.edu.xmu.restfuldemo.model.BO.OrderItem;
import cn.edu.xmu.restfuldemo.model.PO.OrderItemPo;
import cn.edu.xmu.restfuldemo.model.VoObject;
import lombok.*;

import java.time.LocalDateTime;

/**
 * @author RenJie Zheng
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class OrderItemVo implements VoObject {
    private Long id;
    private Long orderId;
    private Long goodsSkuId;
    private Integer quantity;
    private Long price;
    private Long discount;
    private String name;
    private Long couponActivityId;
    private Long beShareId;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;

    public OrderItemVo(OrderItemPo orderItemPo) {
        this.id = orderItemPo.getId();
        this.orderId = orderItemPo.getOrderId();
        this.goodsSkuId = orderItemPo.getGoodsSkuId();
        this.quantity = orderItemPo.getQuantity();
        this.price = orderItemPo.getPrice();
        this.discount = orderItemPo.getDiscount();
        this.name = orderItemPo.getName();
        this.couponActivityId = orderItemPo.getCouponActivityId();
        this.beShareId = orderItemPo.getBeShareId();
        this.gmtCreate = orderItemPo.getGmtCreate();
        this.gmtModified = orderItemPo.getGmtModified();
    }

    /**
     * orderItemVo->orderItem
     * @return orderItemVo
     */
    public OrderItem newOrderItem(){
        OrderItem orderItem = new OrderItem();
        orderItem.setId(this.id);
        orderItem.setOrderId(this.orderId);
        orderItem.setGoodsSkuId(this.goodsSkuId);
        orderItem.setQuantity(this.quantity);
        orderItem.setPrice(this.price);
        orderItem.setDiscount(this.discount);
        orderItem.setName(this.name);
        orderItem.setCouponActivityId(this.couponActivityId);
        orderItem.setBeShareId(this.beShareId);
        orderItem.setGmtCreate(this.gmtCreate);
        orderItem.setGmtModified(this.gmtModified);
        return orderItem;
    }

    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() {
        return this;
    }
}
